Statewide Analysis

Setup

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(lubridate)

Read in Clean Data

df <- read_rds("data-processed/01-storm-data.rds")

df |> glimpse()
Rows: 104,554
Columns: 12
$ EVENT_TYPE        <chr> "Winter Storm", "Winter Storm", "Winter Storm", "Win…
$ INJURIES_DIRECT   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ INJURIES_INDIRECT <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ DEATHS_DIRECT     <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ DEATHS_INDIRECT   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ CZ_TYPE           <chr> "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z", "Z…
$ CZ_FIPS           <dbl> 98, 161, 159, 174, 92, 95, 157, 119, 106, 101, 103, …
$ CZ_NAME           <chr> "HASKELL", "LIMESTONE", "MCLENNAN", "MILAM", "COOKE"…
$ damage_val_prop   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ damage_val_crop   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ begin_date        <date> 2000-01-25, 2000-01-25, 2000-01-25, 2000-01-25, 200…
$ end_date          <date> 2000-01-28, 2000-01-28, 2000-01-28, 2000-01-28, 200…

Answering Questions

Which storm types cause the most damage?

#filter for only events that have damage values for property
damages_property <- df |> filter((!is.na(damage_val_prop)))

damages_property
#now groupby event type and sum up damages
most_damage_property <- damages_property |> group_by(EVENT_TYPE) |> 
  summarize(total_damage_property = sum(damage_val_prop)) |> 
  arrange(total_damage_property |> desc())

most_damage_property

Flash Floods caused the most damage to property in Texas since 2000, totaling over $48 billion in damage. Hail was the second most damaging event type with $11.8 billion in damage.

damages_crops <- df |> filter((!is.na(damage_val_crop)))

damages_crops
most_damage_crop <- damages_crops |> group_by(EVENT_TYPE) |> 
  summarize(total_damage_crop = sum(damage_val_crop)) |> 
  arrange(total_damage_crop |> desc())

most_damage_crop

Droughts caused the most damage to crops in Texas out of all severe weather events with $9.9 billion of damage.

Where did the most damaging storms occur?

sorted_damages_prop <- damages_property |> arrange(damage_val_prop |> desc())

sorted_damages_prop
sorted_damages_crop <- damages_crops |> arrange(damage_val_crop |> desc())

sorted_damages_crop

What year had the most damages?

yr_damage_prop <- damages_property |> group_by(year(begin_date)) |> 
  summarize(total_damage_prop = sum(damage_val_prop)) |> 
  arrange(total_damage_prop |> desc())

yr_damage_crop <- damages_crops |> group_by(year(begin_date)) |> 
  summarize(total_damage_crop = sum(damage_val_crop)) |> 
  arrange(total_damage_crop |> desc())

yr_damage_prop
yr_damage_crop

How have the damages from storm events changed over time?

ggplot(
  damages_property,
  aes(x = begin_date, y = damage_val_prop)
) +
  geom_point()

ggplot(
  damages_crops,
  aes(x = begin_date, y = damage_val_crop)
) +
  geom_point()